<template>
<div class="invite flex-box-div">

    <div class="flex-1 p-15 overflow-y text-left">
        <div class="mt10 bgc-white p15">

            <div class="height-30">我的邀请人：{{pidname}}</div>
            <div class="flex-center-space-between rule van-hairline--bottom fz-14">
                <div class="">邀请列表</div>
                <RouterLink to="/invite-rule" class="price"> 邀请好友规则</RouterLink>
            </div>
            <div class="flex-center pt10 pb10 van-hairline--bottom" @click="memberHandle(item.id,item.name,item.child)" v-for="(item, index) in user_list" :key="index">
                <van-image
                    class="img"
                    fit="contain"
                    :src="item.avatar"
                    lazy-load
                />
                <div class="flex-1 pl10">
                    <p class="fz-12">{{item.name}}</p>
                    <span class="fz-9">间推人数：{{item.child}}</span>
                </div>
                <van-icon name="arrow"></van-icon> 
            </div>
        </div>
    </div>

    <div class="footer bgc-white p10">
        <van-button type="danger" size="small" style="width: 90%" @click="$router.push('/invites')">邀请好友</van-button>
    </div>
</div>
</template>

<script>
export default {
	data () {
	    return {
			user_list:[],
			pidname:'',
			intro:'',
			num:0,
			child:0,
			totalnum:0,
		}
	},
	created: function() {
		
		this.getBaseInfo()
		
	},
    methods: {
        memberHandle (id,name,sum) {
            if (sum > 0) {
                this.$router.push(`/invite?id=${id}&=pidname=${name}`)
            }
        },
		getBaseInfo:function(){
			
			const that = this
			that.$user.getShare().then(function(res){
				const data = res.data||{}
				that.pidname  = data.pidname
				that.intro = data.intro
				that.num = data.num
				that.child = data.child
				that.totalnum = data.totalnum
				that.user_list = data.users||[]
			})
			
			
		
		},
    }
}
</script>

<style lang="less" scoped>
.img {
    height: 40px;
    width: 40px;
}
.rule {
    line-height: 40px;
}
</style>
